<template>
  <div class="like-page">
    <van-nav-bar fixed title="我的点赞" />
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="太深了,到顶啦~"
      @load="onLoad"
    >
      <ArticleItem
        v-for="(item, i) in list"
        :key="i"
        :list="item"
        @click.native="goDetail(item.id)"
      />
    </van-list>
  </div>
</template>

<script>
import { collectList } from "@/api/user.js";
export default {
  name: "like-page",
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
      page: 1,
    };
  },
  methods: {
    async onLoad() {
      // 异步更新数据
      const { data } = await collectList({
        page: this.page,
        pageSize: 5,
        optType: 1
      });
      this.list.push(...data.rows);
      this.loading = false;
      this.page++;

      if (this.page > data.pageTotal) {
        this.finished = true;
      }
    },
    goDetail(id) {
      console.log(id);
      this.$router.push("/detail/" + id);
    },
  },
};
</script>

<style lang="less" scoped>
.like-page {
  margin-bottom: 50px;
  margin-top: 44px;
}
</style>